package com.springweb.unit4.annotated;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class Audience {
	
//	注解          通知
//	@After 通知方法会在目标方法返回或抛出异常后调用
//	@AfterReturning 通知方法会在目标方法返回后调用
//	@AfterThrowing 通知方法会在目标方法抛出异常后调用
//	@Around 通知方法会将目标方法封装起来
//	@Before 通知方法会在目标方法调用之前执行

	@Pointcut("execution(* com.springweb.unit4.Performance.perform(..))")
	public void performance() {
	}
	
	@Before("performance()")
	public void silenceCellPhones() {
		System.out.println("Silencing ecell phones");
	}
	
	@Before("performance()")
	public void takeSeats() {
		System.out.println("Takeing seats");
	}
	
	@AfterReturning("performance()")
	public void applause() {
		System.out.println("CLAP !");
	}
	
	@AfterThrowing("performance()")
	public void demandRefund() {
		System.out.println("Demand a refund");
	}
}
